package thss.mse12.lau.rsa.utils;

import thss.mse12.lau.rsa.b.RSA;

public class Main {
	public static void main(String args[]) throws Exception {
		RSA rsa = new RSA();
		String source = "古之所谓豪杰之士，必有过人之节，人情有所不能忍者。匹夫见辱，拔剑而起，挺身而斗，此不足为勇也。天下有大勇者，卒然临之而不惊，无故加之而不怒，此其所挟持者甚大，而其志甚远也。";
		System.out.println("\r加密前文字：\r\n" + source);
		byte[] data = source.getBytes();
		for (int j = 0; j < data.length; j++) {
			System.out.print(data[j] + ",");
		}
		System.out.println("");

		byte[] encodedData = rsa.encrypt(data);
		for (int i = 0; i < encodedData.length; i++) {
			System.out.print(encodedData[i] + ",");
		}
		System.out.println("");
		byte[] decodedData = rsa.decrypt(encodedData);
		for (int j = 0; j < decodedData.length; j++) {
			System.out.print(decodedData[j] + ",");
		}
		System.out.println("");
		String target = new String(decodedData);
		System.out.println("解密后文字: \r\n" + target);


	}
}
